import Cookies from "js-cookie";
import Config from "../config";

let TokenKey = Config.TokenKey

export const getToken = () => {
  return Cookies.get(TokenKey);
}

export const setToken = (token: string, rememberMe: boolean) => {
  if (rememberMe) {
    return Cookies.set(TokenKey, token, { expires: Config.tokenCookieExpires })
  } else return Cookies.set(TokenKey, token)
}

export const removeToken = () => {
  return Cookies.remove(TokenKey)
}

export const setStorage = (name: string, value: string) => {
  return localStorage.setItem(name, value)
}

export const getStorage = (name: string) => {
  return localStorage.getItem(name)
}

export const removeStorage = (name: string) => {
  return localStorage.removeItem(name)
}